package pt.mauromad.guias.utils.form;

public class Action {
	public enum Method {
		GET, POST, LINK
	};

	private Action(String url, String value, Method method) {
		this.url = url;
		this.value = value;
		this.method = method;
	}

	private final String url;
	private final String value;
	private final Method method;

	public String getUrl() {
		return url;
	}

	public String getValue() {
		return value;
	}

	public Method getMethod() {
		return method;
	}

	public boolean isActionForm() {
		return method.equals(Method.GET) || method.equals(Method.POST);
	}

	public static Action createGet(String value) {
		return createGet(value, "");
	}

	public static Action createGet(String value, String url) {
		return new Action(url, value, Method.GET);
	}

	public static Action createPost(String value) {
		return createPost(value, "");
	}

	public static Action createPost(String value, String url) {
		return new Action(url, value, Method.POST);
	}

	public static Action createLink(String value) {
		return createLink(value, "");
	}

	public static Action createLink(String value, String url) {
		return new Action(url, value, Method.LINK);
	}
}
